﻿using System;

namespace RexToy.UI.Controls
{
    public class Button : ButtonBase
    {
        public Button(string text)
            : base(text)
        {
        }

        public void SetInline(bool inline)
        {
            if (inline)
            {
                this.__domNode.AppendClass("ui-btn-inline");
                this.__orientation = RexToy.UI.Controls.Orientation.Horizental;
            }
            else
            {
                this.__domNode.RemoveClass("ui-btn-inline");
                this.__orientation = RexToy.UI.Controls.Orientation.Vertical;
            }
        }

        public override void SetFirst(bool first)
        {
            if (first)
            {
                if (this.__orientation == RexToy.UI.Controls.Orientation.Vertical)
                    this.__domNode.AppendClass("ui-corner-top");
                if (this.__orientation == RexToy.UI.Controls.Orientation.Horizental)
                    this.__domNode.AppendClass("ui-corner-left");
            }
            else
            {
                if (this.__orientation == RexToy.UI.Controls.Orientation.Vertical)
                    this.__domNode.RemoveClass("ui-corner-top");
                if (this.__orientation == RexToy.UI.Controls.Orientation.Horizental)
                    this.__domNode.RemoveClass("ui-corner-left");
            }
        }

        public override void SetLast(bool last)
        {
            if (last)
            {
                if (this.__orientation == RexToy.UI.Controls.Orientation.Vertical)
                    this.__domNode.AppendClass("ui-corner-bottom");
                if (this.__orientation == RexToy.UI.Controls.Orientation.Horizental)
                    this.__domNode.AppendClass("ui-corner-right");
            }
            else
            {
                if (this.__orientation == RexToy.UI.Controls.Orientation.Vertical)
                    this.__domNode.RemoveClass("ui-corner-bottom");
                if (this.__orientation == RexToy.UI.Controls.Orientation.Horizental)
                    this.__domNode.RemoveClass("ui-corner-right");
            }
        }
    }
}
